from rest_framework import serializers
from apps.recruit.models import Enterprise, Recruit, City
from apps.users.models import User


# 热门城市
class HotCityModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = City
        fields = '__all__'

#访问量序列化器
class EnterpriseVisitSerializer(serializers.ModelSerializer):
    class Meta:
        model = Enterprise
        fields = 'id', 'visits'

class RecruitVisitSerializer(serializers.ModelSerializer):
    class Meta:
        model = Recruit
        fields = 'id', 'visits'

# 公司的序列化器
class EnterpriseModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Enterprise
        fields = '__all__'

#职业的显示
class RecruitModelSerializer(serializers.ModelSerializer):


    class Meta:
        model = Recruit
        fields = '__all__'

# 职业公司详情显示


class UsersSerializer(serializers.ModelSerializer):
    #recruits = RecruitModelSerializer(many=True)
    class Meta:
        model = User
        fields = 'id',


class RecruitDetailsModelSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseModelSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'


class EnterpriseRecruitModelSerializer(serializers.ModelSerializer):

    recruits = RecruitDetailsModelSerializer(many=True)
    users = UsersSerializer(many=True)

    class Meta:
        model = Enterprise
        fields = '__all__'



class RecruitDetailsListSerializer(serializers.ModelSerializer):

    enterprise = EnterpriseRecruitModelSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'

